const express = require("./express");
const app = express(); // express 是一个函数

// 中间件的路径和cookie中的path 是一样的，如果请求的路径以这个路径开头就会执行函数
app.use(
  function (req, res, next) {
    req.a = 100;
    next();
  },
  function (req, res, next) {
    req.a = 100;
    next();
  }
);
app.use("/read", function (req, res, next) {
  req.a += 100;
  next();
});
app.get("/read", function (req, res, next) {
  console.log(req.a);
  res.end("ok");
});

app.listen(3000, function () {
  console.log("server start 3000");
});
